package  
{
	import flash.display.Shape;
	import flash.events.Event;
	
	/**
	 * ...
	 * @author ...
	 */
	public final class Particle extends Shape
	{
		
		private var maxX:Number;
		private var maxY:Number;
		
		private static const FRICTION:Number = 0.1 + Math.random() * 0.9;
		
		public function Particle(x:int = 0, y:int = 0, maxX:Number=500, maxY:Number=350) 
		{
			super();
			this.x = x;
			this.y = y;
			this.maxX = maxX;
			this.maxY = maxY;
			
			graphics.beginFill(0, 1);
			graphics.drawEllipse(-1, -1, 2, 2);
			graphics.endFill();
			
			this.setRandomPosition();
		}
		
		public function move(x:Number, y:Number):void
		{
			this.x += x * FRICTION;
			this.y += y * FRICTION;
			
			if ( this.x < 0)
			{
				this.x += maxX;
			}
			
			if ( this.x >= maxX)
			{
				this.x -= maxX;
			}
						
			if ( this.y < 0)
			{
				this.y += maxY;
			}
			
			if ( this.y >= maxY )
			{
				this.y -= maxY;
			}
		}
		
		public function setRandomPosition():void
		{
			x = Math.random() * (maxX - 1); 
			y = Math.random() * (maxY - 1);
		}
	}

}